package session.stateless;

import entity.MaterialRequirementPlan;
import entity.ProductionSchedule;
import entity.RawMaterial;
import java.util.ArrayList;
import java.util.Date;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateless
public class MaterialRequirementPlanSessionBean implements MaterialRequirementPlanSessionBeanLocal {

    @PersistenceContext
    private EntityManager entityManager;

    @Override
    public void addMaterialRequirementPlan(Date orderDate, Double weight, RawMaterial rawMaterial) {
        RawMaterial rm = entityManager.find(RawMaterial.class, rawMaterial.getId());
        MaterialRequirementPlan materialRequirementPlan = new MaterialRequirementPlan(orderDate, weight, rm);
        
        entityManager.persist(materialRequirementPlan);
        entityManager.flush();
    }
}
